<template>
  <div class="">
    <header class="header">
      <div class="title">
        <img src="../../../assets/images/01_11.png" alt class="img_zuo" @click="jumpReturn" />
        <div>签名</div>
      </div>
    </header>
    <div class="main">
      <div class="signature-title">检查人签名</div>
      <ul class="imgs_ul">
        <li class="signature-show" v-for="(item, index) in dataList" :key="index">
          <div class="signature-img-list">
            <img :src="imgUrl + item.signatureImgUrl" alt="" class="imgs">
            <div class="del-btn" @click.stop="deleteImg(item.id)">
              <p class="del-text">×</p>
            </div>
          </div>
          <p class="signature-text">{{ item.addtime }}</p>
        </li>
      </ul>
      <div class="signature-add-box" @click="jumpSignature">
        <img src="../../../assets/images/jiahao.png" alt="" class="signature-img">
        <p>添加签名</p>
      </div>
    </div>
    <div class="btn-box">
      <div class="btns" @click="jumpList">完成</div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'signature_list',
    data() {
      return {
        routers: '',
        patrolTroubleshootId: 0,
        dataList: [],
        imgUrl: this.$global_msg.Url.hosts + ''
      };
    },
    mounted() {
      var _this = this;
      this.routers = sessionStorage.getItem('signature_router');
      this.patrolTroubleshootId = Number(localStorage.getItem("patrolTroubleshootId"))
      this.query();
    },
    destroyed() {
      setTimeout(() => {
        this.$zoom.showImagesFn.hideContainer();
      })
    },
    methods: {
      query() {
        let params = {
          patrolTroubleshootId: this.patrolTroubleshootId,
          type: 1
        };
        this.axios.get(`${this.$global_msg.Url.host}/partroInspection/signatureSelect`,
          { params }).then(res => {
            if (res.data.code === 200) {
              this.querys(res.data.rows);
            } else {
              this.$toast(res.data.msg);
            }
          }).catch(error => {
            this.$terminal._error(error)
          });
      },
      querys (data) {
       if (data !== '') {
         data.map(res => {
           let b = new Date(res.addtime);
           let c = '0';
           let d = '0';
           if (b.getMonth() >= 10) c = '';
           if (b.getDay() >= 10) d = '';
           let date = `${b.getFullYear()}-${c + (b.getMonth() + 1)}-${d + b.getDate()}`
           let time = `${b.getHours()}:${b.getMinutes()}:${b.getSeconds()}`
           res.addtime = date + '  ' + time
         })
         this.dataList = data;
       } else {
         this.dataList = [];
       }
      },
      //  返回跳转
      jumpReturn() {
        this.$router.back();
      },
      //  删除图片
      deleteImg(id) {
        let params = {
          patrolTroubleshootInfoId: id,
          type: 2
        };
        this.axios.get(`${this.$global_msg.Url.host}/partroInspection/deleteVoice`,
          { params }).then(res => {
            console.log(res);
            if (res.data.code === 200) {
              this.query();
            } else {
              this.$toast(res.data.msg);
            }
          }).catch(error => {
            this.$terminal._error(error)
          });
      },
      //  跳转签名页
      jumpSignature() {
        sessionStorage.setItem('signature', '/signature_list')
        this.$router.push({
          path: '/signature'
        })
      },
      //  跳转列表页
      jumpList() {
        localStorage.removeItem('patrolTroubleshootId_FGD');
        switch (localStorage.getItem('xcpc_scan_fanhui')) {
          case '/index':
            this.$router.go(-6);
            break;
          case '/statistical_patrol':
            this.$router.go(-6);
            break;
          case '/statistical_patrol1':
            this.$router.go(-4);
            break;
          case '/hard_detail':
            this.$router.go(-4);
            break;
          default:
            this.$router.go(-4);
        }
      }
    }
  }
</script>

<style scoped>
  .header {
    z-index: 999;
    height: 1.8519rem;
    background: #007aff;
    padding-top: 0.8333rem;
    box-sizing: border-box;
    position: fixed;
    width: 100%;
    top: 0;
    font-size: 0.388888rem;
  }

  .title {
    padding: 0 0.3704rem;
    display: flex;
    align-items: center;
    color: #fff;
  }

  .title>div {
    width: 100%;
    font-size: 0.4444rem;
    text-align: center;
  }

  .img_zuo {
    width: 0.2593rem;
    height: 0.463rem;
  }

  .main {
    margin-top: 1.8519rem;
    padding: 30px 20px;
    margin-bottom: 1.91852rem;
  }

  .signature-show {
    width: 100%;
  }

  .signature-img-list {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 640px;
    position: relative;
    border: 1px solid #e5e5e5;
    border-radius: 15px;
    overflow: hidden;
  }

  .del-btn {
    z-index: 998;
    position: absolute;
    right: 0;
    top: 0;
    width: 0;
    height: 0;
    border-top: 100px solid #a0a0a0;
    border-left: 100px solid transparent;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .del-text {
    position: absolute;
    right: 10px;
    top: -90px;
    width: 30px;
    height: 30px;
    color: #ffffff;
  }

  .imgs {
    width: 83%;
  }

  .signature-text {
    text-align: right;
    margin-bottom: 20px;
    margin-top: 5px;
    color: #3a3a3a;
  }

  .signature-title {
    margin-bottom: 10px;
    color: #333333;
  }

  .signature-add-box {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    background-color: #eef3f7;
    padding: 200px 0;
    border-radius: 10px;
    width: 100%;
  }

  .signature-img {
    width: 162px;
    margin-bottom: 30px;
  }

  .btn-box {
    z-index: 999;
    position: fixed;
    bottom: 0;
    width: 100%;
    display: flex;
    padding: 50px 50px 100px;
    box-sizing: border-box;
    background-color: #ffffff;
  }

  .btns {
    background-color: #2b6cfe;
    color: #ffffff;
    width: 100%;
    text-align: center;
    margin: 0 5px;
    font-size: 48px;
    padding: 20px 0;
    border-radius: 15px;
  }
</style>
